package java基础.java_base_test;

import java.util.Scanner;

/**
 * @author IT_Jay
 * @date 2022/1/16 11:19
 */

public class TestDemo01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数：");
        int a = scanner.nextInt();
        System.out.println("请输入运算符：");
        String operator = scanner.next();
        System.out.println("请输入第二个数：");
        int b = scanner.nextInt();
        scanner.close();
        TestDemo01 testDemo01 = new TestDemo01();
        int result =0;
        if ("+".equals(operator)){
            result=testDemo01.add(a,b);
        }
        if ("-".equals(operator)){
            result=testDemo01.sub(a,b);
        }
        if ("*".equals(operator)){
            result=testDemo01.mul(a,b);
        }
        if ("/".equals(operator)){
            result=testDemo01.div(a,b);
        }
        System.out.println(result);

    }

    public static int add(int a, int b) {
        return a + b;
    }

    public static int sub(int a, int b) {
        return a - b;
    }

    public static int mul(int a, int b) {
        return a * b;
    }

    public static int div(int a, int b) {
        return a / b;
    }
}
